package test4_15.demo01;

class test2 {
    public static void main(String[] args) {

        System.out.println("开始");

        Two one = new Two();

        new Thread(() -> one.getOne()).start();
        new Thread(() -> one.getTwo()).start();

    }
}


public class Two {

    public synchronized void getOne() {

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        System.out.println("=====1=====");
    }

    public synchronized void getTwo() {
        System.out.println("=====2=====");
    }

}
